/**
 * Classe di esempio
 *
 * @author pietro.
 *         Created 01/mag/2013.
 */
public class Cell2D {
	//Timer timer;
	private float x , y;
	private float red, green, blue;
	private int openGlId;
	private GlWorld2D world;
	public Cell2D(int id, GlWorld2D w, float coordX, float coordY){
		this.world = w;
		this.openGlId = id;
		this.x = coordX;
		this.y = coordY;
	}
	public void Init(){
		GlSquare sq = new GlSquare();
		sq.SetId(this.openGlId);
		sq.SetPos(this.x, this.y, 0);
		sq.SetSquareDim(0.1f);
		this.world.AddGenericObject(sq);
		/*
		this.timer = new Timer();
		this.timer.schedule(new RemindTask(),
                0,        //initial delay
                (int)Math.abs(Math.random()*1000 + 500));
        */
		
	}
	public void SetColor(float r, float g, float b){
		this.red = (r <= 1)? ((r >= 0)? r : 0) : 1;
		this.green = (g <= 1)? ((g >= 0)? g : 0) : 1;
		this.blue = (b <= 1)? ((b >= 0)? b : 0) : 1;
		this.world.GetGlObjectById(this.openGlId).SetObjectColor(this.red, this.green, this.blue);
	}
	/*
	class RemindTask extends TimerTask {
        public void run() {
        	SetColor((((float)Math.random() * 100)/100.0f),
        		(((float)Math.random() * 100)/100.0f),
        		(((float)Math.random() * 100)/100.0f));
            //timer.cancel(); //Terminate the timer thread
        }
    }*/
}
